Skip to content

Comments

libcrun: document vfork shared error#2018

Open
eriksjolund wants to merge 1 commit intocontainers:mainfrom
eriksjolund:document-vfork-shared-error
Open

libcrun: document vfork shared error#2018
eriksjolund wants to merge 1 commit intocontainers:mainfrom
eriksjolund:document-vfork-shared-error

Conversation

@eriksjolund
Copy link
Contributor

@eriksjolund eriksjolund commented Feb 14, 2026

There are examples in the source code where the vfork parent process reuses an error created by the vfork child process. Document that there is no need to create an error in the parent process in such cases.

I've already twice made the mistake to suggest that the missing error is a bug:

See:
#2015
https://github.com/containers/crun/pull/1699/changes#r2009093017

@gemini-code-assist
Copy link

Summary of Changes

Hello @eriksjolund, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the codebase's clarity by adding crucial documentation regarding vfork error handling. It addresses a recurring point of confusion where the parent process reuses errors generated by a vfork child due to shared memory mappings, thereby preventing misinterpretations of the code's intended behavior.

Highlights

  • Documentation Improvement: Added comments to src/libcrun/linux.c and src/libcrun/net_device.c to clarify that vfork child processes share memory mappings with their parents, allowing errors created in the child to be reused by the parent.
  • Preventing Misunderstandings: The added documentation aims to prevent future confusion and incorrect bug reports regarding error handling in vfork contexts, as highlighted by previous related issues.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/libcrun/linux.c
    • Added a comment explaining the shared memory mapping of vfork child processes and the reuse of errors.
  • src/libcrun/net_device.c
    • Added a comment explaining the shared memory mapping of vfork child processes and the reuse of errors.
    • Wrapped the return -get_process_exit_status(wait_status); statement in a new code block for consistency with the added comment.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds comments to src/libcrun/linux.c and src/libcrun/net_device.c to explain why an error object from a vfork() child process can be reused in the parent. This is a useful clarification. The changes are correct. I've provided minor stylistic suggestions to format the new comments as multi-line blocks for better readability, in line with common C coding practices.

Comment on lines 6219 to 6220
/* The vfork child process shares the same memory mapping as its parent process,
so we just reuse the error created in the child process. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment is helpful for clarification. To improve readability and align with common C coding styles (like the Linux kernel style guide) for explanatory comments, consider formatting this as a multi-line block. This avoids a long single line of text.

  /*
   * The vfork() child shares the parent's memory space, so the error
   * object populated by the child is available to the parent.
   */

@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

eriksjolund added a commit to eriksjolund/crun that referenced this pull request Feb 14, 2026
There are examples in the source code where the vfork parent
process reuses an error created by the vfork child process.
Document that there is no need to create an
error in the parent process in such cases.

Related issue:
containers#2015

Amended the suggestion from gemini-code-assist in
containers#2018
with some modifications.

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@eriksjolund eriksjolund force-pushed the document-vfork-shared-error branch 2 times, most recently from ec89e16 to 6f16e5d Compare February 14, 2026 10:23
eriksjolund added a commit to eriksjolund/crun that referenced this pull request Feb 14, 2026
There are examples in the source code where the vfork parent
process reuses an error created by the vfork child process.
Document that there is no need to create an
error in the parent process in such cases.

Related issue:
containers#2015

Amended the suggestion from gemini-code-assist in
containers#2018
with some modifications.

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
eriksjolund added a commit to eriksjolund/crun that referenced this pull request Feb 14, 2026
There are examples in the source code where the vfork parent
process reuses an error created by the vfork child process.
Document that there is no need to create an
error in the parent process in such cases.

Related issue:
containers#2015

Amended the suggestion from gemini-code-assist in
containers#2018
with some modifications.

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@eriksjolund eriksjolund force-pushed the document-vfork-shared-error branch from 6f16e5d to e4ce560 Compare February 14, 2026 10:24
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

There are examples in the source code where the vfork parent
process reuses an error created by the vfork child process.
Document that there is no need to create an
error in the parent process in such cases.

Related issue:
containers#2015

Incorporate a suggestion from gemini-code-assist in
containers#2018

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@eriksjolund eriksjolund force-pushed the document-vfork-shared-error branch from e4ce560 to aecd620 Compare February 15, 2026 12:11
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants